package com.lfnyxy.service.imp;

import com.lfnyxy.dao.BlackListDao;
import com.lfnyxy.entity.BlackListEntity;
import com.lfnyxy.query.BlackListQuery;
import com.lfnyxy.service.BlackListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BlackListServiceImp implements BlackListService {
    @Autowired
    public BlackListDao blackListDao;

    public int CreateItem(BlackListEntity entity) {
        if (entity != null) {
            return blackListDao.CreateItem(entity);
        } else {
            return 0;
        }
    }

    public int UpdateItem(BlackListEntity entity) {
        if (entity != null) {
            return blackListDao.UpdateItem(entity);
        } else {
            return 0;
        }
    }

    public List <BlackListEntity> QueryPageList(BlackListQuery query) {
        int count = blackListDao.QueryPageListCount(query);
        query.setTotal(count);
        return blackListDao.QueryPageList(query);
    }

    public List <BlackListEntity> QueryAll() {
        return blackListDao.QueryAll();
    }

    public BlackListEntity QueryItem(int Id) {
        if (Id > 0) {
            return blackListDao.QueryItem(Id);
        } else {
            return null;
        }
    }

    public int DeleteItem(int Id) {
        if (Id > 0) {
            return blackListDao.DeleteItem(Id);
        } else {
            return 0;
        }
    }

    private boolean CheckIsExist(BlackListEntity entity) {
        if (entity != null) {
            return blackListDao.CheckIsExist(entity) > 0;
        } else {
            return false;
        }
    }
}